<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0"><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> 
        <title>Welcome to Design Zone......</title>
        <link rel="stylesheet" type="text/css" href="../../scripts/ext/resources/css/ext-all.css" />
        <link rel="stylesheet" type="text/css" href="../../scripts/ext/resources/css/file-upload.css" />
        <link rel="stylesheet" type="text/css" href="../../styles/dzbase.css" />
        <script type="text/javascript" src="../../scripts/ext/adapter/ext-base.js">
        </script>
        <script type="text/javascript" src="../../scripts/ext/ext-all.js">
        </script>
		<script type="text/javascript" src="../../scripts/grid/GroupSummary.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/RowExpander.js">
        </script>
        <script type="text/javascript" src="../../scripts/menu/EditableItem.js">
        </script>
        <script type="text/javascript" src="../../scripts/menu/RangeMenu.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/GridFilters.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/filter/Filter.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/filter/StringFilter.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/filter/ListFilter.js">
        </script>
        <script type="text/javascript" src="../../scripts/form/FileUploadField.js">
        </script>
        <script type="text/javascript" src="../../scripts/i18nMessage.js">
        </script>
        <script type="text/javascript" src="../../scripts/utils.js">
        </script>
        <script type="text/javascript">
            var piMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.productidentification');
            var fcMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.francecustomer');
			var fMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.factory');
			var aoMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.accessoryothers');
			var referenceMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.reference');
            var message = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=message');
			
			var ctYesnoXmlLoader = new xmlLoader('../../servlet/CodeTableServlet?name=CtYesno');
            
            var ctYesnoStore = new Ext.data.Store({
                   
                    reader: new Ext.data.XmlReader({
                        record: 'item',
                        id: 'code',
                        totalRecords: 'itemTotal'
                    }, [
                    'code', 'description']),
					data: ctYesnoXmlLoader.getXml()
                });
                
            var isDZBuyCombo = new Ext.form.ComboBox({
					fieldLabel: message.get('message.edit.isdzbuy'),
					id: 'isDZBuy',
					name: 'isDZBuy',
					editable: false,
					valueField: 'code',
				    store: ctYesnoStore,
				    displayField:'description',
				    anchor: '76%',
					width: '80%',
				    triggerAction: 'all',
				    emptyText: message.get('message.combo.pleaseselect'),
					allowBlank: false,
                    blankText: message.get('message.edit.noblank'),
				    selectOnFocus:true,
					mode: 'local'
				});
				
			var idValue = getPrarmeterValue(window.location, 'id');
            var startPage = getPrarmeterValue(window.location, 'startPage');
			var input = getPrarmeterValue(window.location, 'input');
			
			var piHangForm
            var piHangStore;
            var piHangGrid;
            
            var piXMLReader = new Ext.data.XmlReader({
                   record: 'item'
               }, [{
                   name: 'id',
                   mapping: 'id'
               }, {
                   name: 'ctProductFamily',
                   mapping: 'ctProductFamily'
               }, {
                   name: 'ctMachineType',
                   mapping: 'ctMachineType'
               }, {
                   name: 'type',
                   mapping: 'type'
               }, {
                   name: 'orderNumber',
                   mapping: 'orderNumber'
               }, {
                   name: 'yarnNumber',
                   mapping: 'yarnNumber'
               }, {
                   name: 'ctDesignType',
                   mapping: 'ctDesignType'
               }, {
                   name: 'style',
                   mapping: 'style'
               }, {
                   name: 'customerLinkman',
                   mapping: 'customerLinkman'
               }, {
                   name: 'model',
                   mapping: 'model'
               }, {
                   name: 'ctSeasonNumber',
                   mapping: 'ctSeasonNumber'
               }, {
                   name: 'ctSeasonNumberCode',
                   mapping: 'ctSeasonNumberCode'
               }, {
                   name: 'reference',
                   mapping: 'reference'
               }, {
                   name: 'createDate',
                   mapping: 'createDate'
               }, {
                   name: 'ctVersion',
                   mapping: 'ctVersion'
               }, {
                   name: 'patronageNumer',
                   mapping: 'patronageNumer'
               }, {
                   name: 'front',
                   mapping: 'front'
               }, {
                   name: 'back',
                   mapping: 'back'
               }, {
                   name: 'sleeves',
                   mapping: 'sleeves'
               }, {
                   name: 'bottomThrum',
                   mapping: 'bottomThrum'
               }, {
                   name: 'sleevesThrum',
                   mapping: 'sleevesThrum'
               }, {
                   name: 'necklineThrum',
                   mapping: 'necklineThrum'
               }, {
                   name: 'needle',
                   mapping: 'needle'
               }, {
                   name: 'weight',
                   mapping: 'weight'
               }, {
                   name: 'comment',
                   mapping: 'comment'
               }, {
                   name: 'customerID',
                   mapping: 'customerID'
               }, {
                   name: 'photoName',
                   mapping: 'photoName'
               }, {
                   name: 'chartName',
                   mapping: 'chartName'
               }, {
                   name: 'biMeasureSpecificationId',
                   mapping: 'biMeasureSpecificationId'
               }, {
                   name: 'biMeasureSpecificationName',
                   mapping: 'biMeasureSpecificationName'
               }, {
                   name: 'yarnName',
                   mapping: 'yarnName'
               }, {
                   name: 'frontPhotoName',
                   mapping: 'frontPhotoName'
               }, {
                   name: 'backPhotoName',
                   mapping: 'backPhotoName'
               }, {
                   name: 'photoName',
                   mapping: 'photoName'
               }, {
                   name: 'chartName',
                   mapping: 'chartName'
               }, {
                   name: 'ctCollarType',
                   mapping: 'ctCollarType'
               }, {
                   name: 'customerName',
                   mapping: 'customerName'
               }, {
                   name: 'customerDepartment',
                   mapping: 'customerDepartment'
               }, {
                   name: 'referenceAs',
                   mapping: 'referenceAs'
               }, {
                   name: 'createDate',
                   mapping: 'createDate'
               }]);
                
              var piXmlLoader = new xmlLoader('../../servlet/ProductIdentificationServlet?action=11&id=' + idValue);
              
              var piRecord = piXMLReader.readRecords(piXmlLoader.getXml()).records[0];
              
              var itemTplMarkup = ['<table cellspacing="0" id="the-table" style="width: 100%;"><tbody>',
								 '<tr><td style="background:#eeeeee; width: 15%;">',
								 message.get('message.list.id'), '</td><td>{id}</td>', 
								 '<td style="background:#eeeeee;width: 15%;">', 
								 piMessage.get('ui.productidentification.style'), 
								 '</td><td>{style}</td><td style="background:#eeeeee;">', 
								 piMessage.get('ui.productidentification.seasonnumber'), 
								 '</td><td>{ctSeasonNumber}</td>', '<td style="background:#eeeeee;">', 
								 referenceMessage.get('ui.reference.reference'), 
								 '</td><td>{reference}</td></tr>', 
								 
								 
								 '<tr><td style="background:#eeeeee;">', 
								message.get('message.edit.createdate') + "(d/m/Y)",
								 '</td><td>{createDate}</td><td style="background:#eeeeee;">', 
								piMessage.get('ui.productidentification.designtype'), 
								 '</td><td>{ctDesignType}</td><td style="background:#eeeeee;">', 
								 piMessage.get('ui.productidentification.chartversion'), 
								 '</td><td>{ctVersion}</td><td style="background:#eeeeee;">', 
								 piMessage.get('ui.productidentification.referenceas'), 
								 '</td><td>{referenceAs}</td></tr>',
								 
								 '<tr><td style="background:#eeeeee;">', 
								 referenceMessage.get('ui.reference.weight') + '(Kg)', 
								 '</td><td>{weight}</td><td style="background:#eeeeee;">', 
								 message.get('message.edit.collar'), 
								 '</td><td>{ctCollarType}</td><td style="background:#eeeeee;">', 
								 fcMessage.get('ui.francecustomer.name'), 
								 '</td><td>{customerName}</td><td style="background:#eeeeee;">', 
								 fcMessage.get('ui.francecustomer.department'), 
								 '</td><td>{customerDepartment}</td></tr>',
								 
								 '<tr><td colspan="8">',
								 //'<img width="120" src="../../_temp/{frontPhotoName}"/>&nbsp;&nbsp;&nbsp;&nbsp;',
								 //'<img width="120" src="../../_temp/{backPhotoName}"/>&nbsp;&nbsp;&nbsp;&nbsp;',
								 '<img width="120" src="../../_temp/{chartName}"/>&nbsp;&nbsp;&nbsp;&nbsp;',
								 '<img width="120" src="../../_temp/{photoName}"/>',
								 '</td></tr>',
								 '</tbody></table>'];
              var itemTpl = new Ext.Template(itemTplMarkup);
  			var selectProductAccessoryOthersCallback = function(aoId, applicationReference, accessoryReference, customerName, customerDepartment, 
  					customerReference,customerColor,factoryName,addressFactory, 
  					photo1Name, photo2Name,ctApplicationType,ctAccessoryType,
  					ctAccessoryTypeCode){

  			}
  			var ahIndex;
  			var selectProductAccessoryOthersCallback = function(){
	  			Ext.getCmp('aoId' + ahIndex).setValue(parent.selectedAccessoryOthers.id);;
				Ext.getCmp('accessoryReference' + ahIndex).setValue(parent.selectedAccessoryOthers.accessoryReference);
				Ext.getCmp('customerReference' + ahIndex).setValue(parent.selectedAccessoryOthers.customerReference);
				Ext.getCmp('ctAccessoryType' + ahIndex).setValue(parent.selectedAccessoryOthers.ctAccessoryType);
	  		}
		  		
            Ext.onReady(function(){
                Ext.QuickTips.init();
                Ext.form.Field.prototype.msgTarget = 'side';
                
                //itemTpl.append('productIdentification', piRecord.data);
                
				piHangForm = new Ext.FormPanel({
					fileUpload: true,
                    labelAlign: 'left',
                    url: '../../servlet/ProductAccessoryHangServlet?action=1',
                    frame: true,
                    title: aoMessage.get('ui.accessoryothers.hang'),
                    bodyStyle: 'padding:5px 5px 5px 5px;margin-top: 2px;',
                    width: '100%',
                    labelWidth: 105,
                    collapsible: true,
                    //collapsed: true,
                    reader: new Ext.data.XmlReader({
                        record: 'item'
                    }, [{
                        name: 'id',
                        mapping: 'id'
                    }, {
                        name: 'aoId1',
                        mapping: 'aoId1'
                    }, {
                        name: 'accessoryReference1',
                        mapping: 'accessoryReference1'
                    },{
                        name: 'ctAccessoryType1',
                        mapping: 'ctAccessoryType1'
                    },{
                        name: 'customerReference1',
                        mapping: 'customerReference1'
                    }, {
                        name: 'aoId2',
                        mapping: 'aoId2'
                    }, {
                        name: 'accessoryReference2',
                        mapping: 'accessoryReference2'
                    },{
                        name: 'ctAccessoryType2',
                        mapping: 'ctAccessoryType2'
                    },{
                        name: 'customerReference2',
                        mapping: 'customerReference2'
                    }, {
                        name: 'aoId3',
                        mapping: 'aoId3'
                    }, {
                        name: 'accessoryReference3',
                        mapping: 'accessoryReference3'
                    },{
                        name: 'ctAccessoryType3',
                        mapping: 'ctAccessoryType3'
                    },{
                        name: 'customerReference3',
                        mapping: 'customerReference3'
                    }, {
                        name: 'aoId4',
                        mapping: 'aoId4'
                    }, {
                        name: 'accessoryReference4',
                        mapping: 'accessoryReference4'
                    },{
                        name: 'ctAccessoryType4',
                        mapping: 'ctAccessoryType4'
                    },{
                        name: 'customerReference4',
                        mapping: 'customerReference4'
                    }, {
                        name: 'aoId5',
                        mapping: 'aoId5'
                    }, {
                        name: 'accessoryReference5',
                        mapping: 'accessoryReference5'
                    },{
                        name: 'ctAccessoryType5',
                        mapping: 'ctAccessoryType5'
                    },{
                        name: 'customerReference5',
                        mapping: 'customerReference5'
                    }, {
                        name: 'aoId6',
                        mapping: 'aoId6'
                    }, {
                        name: 'accessoryReference6',
                        mapping: 'accessoryReference6'
                    },{
                        name: 'ctAccessoryType6',
                        mapping: 'ctAccessoryType6'
                    },{
                        name: 'customerReference6',
                        mapping: 'customerReference6'
                    }, {
                        name: 'descriptionFR',
                        mapping: 'descriptionFR'
                    }, {
                        name: 'descriptionCN',
                        mapping: 'descriptionCN'
                    }, {
                        name: 'descriptionEN',
                        mapping: 'descriptionEN'
                    }]),
                    items: [{
                        id: 'id',
                        name: 'id',
                        xtype: 'hidden'
                    }, {
                        id: 'aoId1',
                        name: 'aoId1',
                        xtype: 'hidden'
                    }, {
                        id: 'aoId2',
                        name: 'aoId2',
                        xtype: 'hidden'
                    }, {
                        id: 'aoId3',
                        name: 'aoId3',
                        xtype: 'hidden'
                    }, {
                        id: 'aoId4',
                        name: 'aoId4',
                        xtype: 'hidden'
                    }, {
                        id: 'aoId5',
                        name: 'aoId5',
                        xtype: 'hidden'
                    }, {
                        id: 'aoId6',
                        name: 'aoId6',
                        xtype: 'hidden'
                    }, {
                        id: 'piId',
                        name: 'piId',
						value: piRecord.data.id,
                        xtype: 'hidden'
                    }, {
                        layout: 'column',
                        items: [{
                            columnWidth: .33,
                            layout: 'form',
                            items: [{
                                xtype: 'textfield',
                                fieldLabel: aoMessage.get('ui.accessoryothers.reference') + '1',
                                id: 'accessoryReference1',
                                name: 'accessoryReference1',
                                anchor: '86%',
                                allowBlank: false,
                                blankText: message.get('message.edit.noblank'),
                                emptyText: message.get('message.combo.pleaseselect'),
                                maxLength: 64,
                                tabIndex: 1,
                                readOnly: true,
                                listeners: {
		                            'render': {
                                            fn: function(){
                                                Ext.getCmp('accessoryReference1').getEl().on('click', function(){
                                                	ahIndex = 1;
                                    				parent.selectProductAccessoryOthers(selectProductAccessoryOthersCallback, piRecord.data.id);
                                                }, this);
                                            },
                                            scope: this
                                        }
                                }
                            }]
                        },{
                            columnWidth: .33,
                            layout: 'form',
                            items: [{
                                name: 'customerReference1',
                                id: 'customerReference1',
                                fieldLabel: aoMessage.get('ui.accessoryothers.customerreference') + '1',
                                xtype: 'textfield',
                                anchor: '86%',
                                readOnly: true,
                                //allowBlank: false,
                                //blankText: message.get('message.edit.noblank'),
                                maxLength: 64
                            }]
                        },{
                            columnWidth: .33,
                            layout: 'form',
                            items: [{
                                name: 'ctAccessoryType1',
                                id: 'ctAccessoryType1',
                                fieldLabel: aoMessage.get('ui.accessoryothers.type') + '1',
                                xtype: 'textfield',
                                anchor: '86%',
                                readOnly: true,
                                //allowBlank: false,
                                //blankText: message.get('message.edit.noblank'),
                                maxLength: 64
                            }]
                        }]
                    
                    },{
                        xtype: 'fieldset',
                        collapsible: true,
                        collapsed: true,
                        id: 'ahSet',
                        title: '&nbsp;',
                        autoHeight: true,
                        items: [{
                            layout: 'column',
                            items: [{
                                columnWidth: .33,
                                layout: 'form',
                                items: [{
                                    xtype: 'textfield',
                                    fieldLabel: aoMessage.get('ui.accessoryothers.reference') + '2',
                                    id: 'accessoryReference2',
                                    name: 'accessoryReference2',
                                    anchor: '86%',
                                    //allowBlank: false,
                                    blankText: message.get('message.edit.noblank'),
                                    emptyText: message.get('message.combo.pleaseselect'),
                                    maxLength: 64,
                                    tabIndex: 1,
                                    readOnly: true,
                                    listeners: {
    		                            'render': {
                                                fn: function(){
                                                    Ext.getCmp('accessoryReference2').getEl().on('click', function(){
                                                    	ahIndex = 2;
                                                    	parent.selectProductAccessoryOthers(selectAccessoryOthersCallback);
                                                    }, this);
                                                },
                                                scope: this
                                            }
                                    }
                                },{
                                    xtype: 'textfield',
                                    fieldLabel: aoMessage.get('ui.accessoryothers.reference') + '3',
                                    id: 'accessoryReference3',
                                    name: 'accessoryReference3',
                                    anchor: '86%',
                                    //allowBlank: false,
                                    blankText: message.get('message.edit.noblank'),
                                    emptyText: message.get('message.combo.pleaseselect'),
                                    maxLength: 64,
                                    tabIndex: 1,
                                    readOnly: true,
                                    listeners: {
    		                            'render': {
                                                fn: function(){
                                                    Ext.getCmp('accessoryReference3').getEl().on('click', function(){
                                                    	ahIndex = 3;
                                                    	parent.selectProductAccessoryOthers(selectAccessoryOthersCallback);
                                                    }, this);
                                                },
                                                scope: this
                                            }
                                    }
                                },{
                                    xtype: 'textfield',
                                    fieldLabel: aoMessage.get('ui.accessoryothers.reference') + '4',
                                    id: 'accessoryReference4',
                                    name: 'accessoryReference4',
                                    anchor: '86%',
                                    //allowBlank: false,
                                    blankText: message.get('message.edit.noblank'),
                                    emptyText: message.get('message.combo.pleaseselect'),
                                    maxLength: 64,
                                    tabIndex: 1,
                                    readOnly: true,
                                    listeners: {
    		                            'render': {
                                                fn: function(){
                                                    Ext.getCmp('accessoryReference4').getEl().on('click', function(){
                                                    	ahIndex = 4;
                                                    	parent.selectProductAccessoryOthers(selectAccessoryOthersCallback);
                                                    }, this);
                                                },
                                                scope: this
                                            }
                                    }
                                },{
                                    xtype: 'textfield',
                                    fieldLabel: aoMessage.get('ui.accessoryothers.reference') + '5',
                                    id: 'accessoryReference5',
                                    name: 'accessoryReference5',
                                    anchor: '86%',
                                    //allowBlank: false,
                                    blankText: message.get('message.edit.noblank'),
                                    emptyText: message.get('message.combo.pleaseselect'),
                                    maxLength: 64,
                                    tabIndex: 1,
                                    readOnly: true,
                                    listeners: {
    		                            'render': {
                                                fn: function(){
                                                    Ext.getCmp('accessoryReference5').getEl().on('click', function(){
                                                    	ahIndex = 5;
                                                    	parent.selectProductAccessoryOthers(selectAccessoryOthersCallback);
                                                    }, this);
                                                },
                                                scope: this
                                            }
                                    }
                                },{
                                    xtype: 'textfield',
                                    fieldLabel: aoMessage.get('ui.accessoryothers.reference') + '6',
                                    id: 'accessoryReference6',
                                    name: 'accessoryReference6',
                                    anchor: '86%',
                                    //allowBlank: false,
                                    blankText: message.get('message.edit.noblank'),
                                    emptyText: message.get('message.combo.pleaseselect'),
                                    maxLength: 64,
                                    tabIndex: 1,
                                    readOnly: true,
                                    listeners: {
    		                            'render': {
                                                fn: function(){
                                                    Ext.getCmp('accessoryReference6').getEl().on('click', function(){
                                                    	ahIndex = 6;
                                                    	parent.selectProductAccessoryOthers(selectAccessoryOthersCallback);
                                                    }, this);
                                                },
                                                scope: this
                                            }
                                    }
                                }]
                            },{
                                columnWidth: .33,
                                layout: 'form',
                                items: [{
                                    name: 'customerReference2',
                                    id: 'customerReference2',
                                    fieldLabel: aoMessage.get('ui.accessoryothers.customerreference') + '2',
                                    xtype: 'textfield',
                                    anchor: '86%',
                                    readOnly: true,
                                    //allowBlank: false,
                                    //blankText: message.get('message.edit.noblank'),
                                    maxLength: 64
                                },{
                                    name: 'customerReference3',
                                    id: 'customerReference3',
                                    fieldLabel: aoMessage.get('ui.accessoryothers.customerreference') + '3',
                                    xtype: 'textfield',
                                    anchor: '86%',
                                    readOnly: true,
                                    //allowBlank: false,
                                    //blankText: message.get('message.edit.noblank'),
                                    maxLength: 64
                                },{
                                    name: 'customerReference4',
                                    id: 'customerReference4',
                                    fieldLabel: aoMessage.get('ui.accessoryothers.customerreference') + '4',
                                    xtype: 'textfield',
                                    anchor: '86%',
                                    readOnly: true,
                                    //allowBlank: false,
                                    //blankText: message.get('message.edit.noblank'),
                                    maxLength: 64
                                },{
                                    name: 'customerReference5',
                                    id: 'customerReference5',
                                    fieldLabel: aoMessage.get('ui.accessoryothers.customerreference') + '5',
                                    xtype: 'textfield',
                                    anchor: '86%',
                                    readOnly: true,
                                    //allowBlank: false,
                                    //blankText: message.get('message.edit.noblank'),
                                    maxLength: 64
                                },{
                                    name: 'customerReference6',
                                    id: 'customerReference6',
                                    fieldLabel: aoMessage.get('ui.accessoryothers.customerreference') + '6',
                                    xtype: 'textfield',
                                    anchor: '86%',
                                    readOnly: true,
                                    //allowBlank: false,
                                    //blankText: message.get('message.edit.noblank'),
                                    maxLength: 64
                                }]
                            },{
                                columnWidth: .33,
                                layout: 'form',
                                items: [{
                                    name: 'ctAccessoryType2',
                                    id: 'ctAccessoryType2',
                                    fieldLabel: aoMessage.get('ui.accessoryothers.type') + '2',
                                    xtype: 'textfield',
                                    anchor: '86%',
                                    readOnly: true,
                                    //allowBlank: false,
                                    //blankText: message.get('message.edit.noblank'),
                                    maxLength: 64
                                },{
                                    name: 'ctAccessoryType3',
                                    id: 'ctAccessoryType3',
                                    fieldLabel: aoMessage.get('ui.accessoryothers.type') + '3',
                                    xtype: 'textfield',
                                    anchor: '86%',
                                    readOnly: true,
                                    //allowBlank: false,
                                    //blankText: message.get('message.edit.noblank'),
                                    maxLength: 64
                                },{
                                    name: 'ctAccessoryType4',
                                    id: 'ctAccessoryType4',
                                    fieldLabel: aoMessage.get('ui.accessoryothers.type') + '4',
                                    xtype: 'textfield',
                                    anchor: '86%',
                                    readOnly: true,
                                    //allowBlank: false,
                                    //blankText: message.get('message.edit.noblank'),
                                    maxLength: 64
                                },{
                                    name: 'ctAccessoryType5',
                                    id: 'ctAccessoryType5',
                                    fieldLabel: aoMessage.get('ui.accessoryothers.type') + '5',
                                    xtype: 'textfield',
                                    anchor: '86%',
                                    readOnly: true,
                                    //allowBlank: false,
                                    //blankText: message.get('message.edit.noblank'),
                                    maxLength: 64
                                },{
                                    name: 'ctAccessoryType6',
                                    id: 'ctAccessoryType6',
                                    fieldLabel: aoMessage.get('ui.accessoryothers.type') + '6',
                                    xtype: 'textfield',
                                    anchor: '86%',
                                    readOnly: true,
                                    //allowBlank: false,
                                    //blankText: message.get('message.edit.noblank'),
                                    maxLength: 64
                                }]
                            }]
                        
                        }]
                    },{
                        layout: 'column',
                        items: [{
                            columnWidth: .33,
                            layout: 'form',
                            items: [{
                                fieldLabel: message.get('message.edit.descriptionfr'),
                                name: 'descriptionFR',
                                xtype: 'textarea',
                                maxLength: 2048,
                                width: '90%',
                                maxLengthText: message.get('message.edit.toolong')
                            }]
                        }, {
                            columnWidth: .33,
                            layout: 'form',
                            items: [{
                                fieldLabel: message.get('message.edit.descriptioncn'),
                                name: 'descriptionCN',
                                xtype: 'textarea',
                                maxLength: 2048,
                                width: '90%',
                                maxLengthText: message.get('message.edit.toolong')
                            }]
                        }, {
                            columnWidth: .33,
                            layout: 'form',
                            items: [{
                                fieldLabel: message.get('message.edit.descriptionen'),
                                name: 'descriptionEN',
                                xtype: 'textarea',
                                maxLength: 2048,
                                width: '90%',
                                maxLengthText: message.get('message.edit.toolong')
                            }]
                        }]
                    },{
                        xtype: 'fileuploadfield',
                        width: '20%',
                        id: 'photo',
                        emptyText: message.get('message.edit.selectimage'),
                        fieldLabel: message.get('message.edit.photo'),
                        name: 'photo',
                        buttonCfg: {
                            text: '',
                            iconCls: 'uploadIcon'
                        }
                    }],
                    
                    buttons: [{
                        text: message.get('message.edit.save'),
                        handler: function(){
                            if (piHangForm.getForm().isValid()) {
                                piHangForm.getForm().submit({
                                    method: 'post',
                                    success: function(form, action){
                                    	piHangStore.reload();
                                        messageTip.msg(message.get('message.tip'), message.get('message.edit.successful'));
                                        piHangForm.getForm().reset();
                                        document.getElementById('photo-file').value = null;
                                        Ext.getCmp('ahSet').collapse();
                                    },
                                    failure: function(form, action){
                                        messageTip.msg(message.get('message.tip'), message.get('message.edit.unsuccessful'));
                                    }
                                });
                            }
                        }
                    }, {
                        text: message.get('message.edit.reset'),
                        handler: function(){
                            piHangForm.getForm().reset();
                        }
                    }, {
                        text: message.get('message.edit.cancel'),
                        handler: function(){
                        	if(input == 'history'){
								if (startPage != null) {
	                                parent.window.location = 'product_identification_history_list.html?startPage=' + startPage;
	                            }else {
	                                parent.window.location = 'product_identification_history_list.html';
	                            }
	                            return;
							}
                            if (startPage != null) {
                                parent.window.location = 'product_identification_list.html?startPage=' + startPage;
                            }
                            else {
                                parent.window.location = 'product_identification_list.html';
                            }
                        }
                    }]
                });
				//piHangForm.render('piAccessoryOthersForm');
				
				piHangStore = new Ext.data.Store({
                    url: '../../servlet/ProductAccessoryHangServlet?action=5&id=' + piRecord.data.id,
                    
                    reader: new Ext.data.XmlReader({
                        record: 'item',
                        id: 'id',
                        totalRecords: 'itemTotal'
                    }, ['index','id', 'aoReference', 
						'ctAccessoryType1', 'accessoryReference1', 'customerReference1',
						'ctAccessoryType2', 'accessoryReference2', 'customerReference2',
						'ctAccessoryType3', 'accessoryReference3', 'customerReference3',
						'ctAccessoryType4', 'accessoryReference4', 'customerReference4',
						'ctAccessoryType5', 'accessoryReference5', 'customerReference5',
						'ctAccessoryType6', 'accessoryReference6', 'customerReference6',
						'comment', 'isDZBuy',
						{
							name:'unitNumber',
							type: 'int'
						},{
							name:'stock',
							type: 'int'
						},{
							name:'total',
							type: 'int'
						},'ctCareLabelMaterial', 'percentage','sequence','ctMaterialType', 'factoryName','photoName',
						 'ctCareLabelMaterial', 'percentage', 'descriptionCN','descriptionFR','descriptionEN'
						 ,'customerReference', 'customerColor',
						 'factoryReference', 'factoryColor'  ]),
						
						sortInfo:{
	                    	field: 'id',
	                    	direction: 'ASC'
	                    }
                });

				var expander = new Ext.grid.RowExpander({
			        tpl : new Ext.XTemplate(
						'{[this.getAccessoryOther(values)]}',
			        	'<p><img src="../../_temp/{photoName}" width="150px" style="cursor: hand;" onclick="parent.openImageViewer(this.src);"/></p>',
						'<br/><p><b>' + message.get('message.edit.descriptionfr') + ':</b> {descriptionFR}</p><br/>',
						'<br/><p><b>' + message.get('message.edit.descriptioncn') + ':</b> {descriptionCN}</p><br/>',
						'<br/><p><b>' + message.get('message.edit.descriptionen') + ':</b> {descriptionEN}</p><br/>',{
						     getAccessoryOther: function(values){
						     	 var rtn = '';
							     if(values.accessoryReference2 != ''){
								     rtn += '<p><b>';
									 rtn += aoMessage.get('ui.accessoryothers.reference') + '2:</b>&nbsp;&nbsp;'+ values.accessoryReference2 + '&nbsp;&nbsp;&nbsp;&nbsp;<b>';
									 rtn += aoMessage.get('ui.accessoryothers.customerreference') + '2:</b>&nbsp;&nbsp;'+ values.customerReference2 + '&nbsp;&nbsp;&nbsp;&nbsp;<b>';
									 rtn += aoMessage.get('ui.accessoryothers.type') + '2:</b>&nbsp;&nbsp;'+ values.ctAccessoryType2
								     rtn += '</p><br/>'
							     }

							     if(values.accessoryReference3 != ''){
								     rtn += '<p><b>';
									 rtn += aoMessage.get('ui.accessoryothers.reference') + '3:</b>&nbsp;&nbsp;'+ values.accessoryReference3 + '&nbsp;&nbsp;&nbsp;&nbsp;<b>';
									 rtn += aoMessage.get('ui.accessoryothers.customerreference') + '3:</b>&nbsp;&nbsp;'+ values.customerReference3 + '&nbsp;&nbsp;&nbsp;&nbsp;<b>';
									 rtn += aoMessage.get('ui.accessoryothers.type') + '3:</b>&nbsp;&nbsp;'+ values.ctAccessoryType3
								     rtn += '</p><br/>'
							     }

							     if(values.accessoryReference4 != ''){
								     rtn += '<p><b>';
									 rtn += aoMessage.get('ui.accessoryothers.reference') + '4:</b>&nbsp;&nbsp;'+ values.accessoryReference4 + '&nbsp;&nbsp;&nbsp;&nbsp;<b>';
									 rtn += aoMessage.get('ui.accessoryothers.customerreference') + '4:</b>&nbsp;&nbsp;'+ values.customerReference4 + '&nbsp;&nbsp;&nbsp;&nbsp;<b>';
									 rtn += aoMessage.get('ui.accessoryothers.type') + '4:</b>&nbsp;&nbsp;'+ values.ctAccessoryType4
								     rtn += '</p><br/>'
							     }

							     if(values.accessoryReference5 != ''){
								     rtn += '<p><b>';
									 rtn += aoMessage.get('ui.accessoryothers.reference') + '5:</b>&nbsp;&nbsp;'+ values.accessoryReference5 + '&nbsp;&nbsp;&nbsp;&nbsp;<b>';
									 rtn += aoMessage.get('ui.accessoryothers.customerreference') + '5:</b>&nbsp;&nbsp;'+ values.customerReference5 + '&nbsp;&nbsp;&nbsp;&nbsp;<b>';
									 rtn += aoMessage.get('ui.accessoryothers.type') + '5:</b>&nbsp;&nbsp;'+ values.ctAccessoryType5
								     rtn += '</p><br/>'
							     }

							     if(values.accessoryReference6 != ''){
								     rtn += '<p><b>';
									 rtn += aoMessage.get('ui.accessoryothers.reference') + '6:</b>&nbsp;&nbsp;'+ values.accessoryReference6 + '&nbsp;&nbsp;&nbsp;&nbsp;<b>';
									 rtn += aoMessage.get('ui.accessoryothers.customerreference') + '6:</b>&nbsp;&nbsp;'+ values.customerReference6 + '&nbsp;&nbsp;&nbsp;&nbsp;<b>';
									 rtn += aoMessage.get('ui.accessoryothers.type') + '6:</b>&nbsp;&nbsp;'+ values.ctAccessoryType6
								     rtn += '</p><br/>'
							     }
							     return rtn;
					         
					     }
						}
			        )
			    });

				piHangGrid = new Ext.grid.GridPanel({
                    title: aoMessage.get('ui.accessoryothers.hang'),
                    store: piHangStore,
                    plugins: [expander],
                    stripeRows: true,
                    height: 380,
                    columns: [
                    /*{
                        header: message.get('message.list.id'),
                        width: 50,
                        dataIndex: 'index',
                        sortable: false,
                    },*/expander,
                    {
                        header: aoMessage.get('ui.accessoryothers.reference') + '1',
                        dataIndex: 'accessoryReference1'
                    },{
                        header: aoMessage.get('ui.accessoryothers.customerreference') + '1',
                        dataIndex: 'customerReference1'
                    },{
                        header: aoMessage.get('ui.accessoryothers.type') + '1',
                        dataIndex: 'ctAccessoryType1'
                    }
                    /*,{
                        header: message.get('message.list.eidt'),
                        width: 50,
                        dataIndex: 'id',
                        sortable: false,
                        renderer: renderEdit
                    },{
                        header: message.get('message.list.delete'),
                        width: 50,
                        dataIndex: 'id',
                        sortable: false,
                        renderer: renderDelete
                    }*/],
                    viewConfig: {
                        forceFit: true
                    },
                    loadMask: true,
                    renderTo: 'piAccessoryOthersList'
                });
				
				piHangStore.load();
				
                
            });
			
			function renderEdit(value, p, record){
                    return String.format('<a href="javascript:piHangForm.expand(true); editItem(editCallback, {0});"><img src="../../images/icons/pencil.png" title="Edition" /></a>', record.id);
                }
                
            function renderDelete(value, p, record){
                return String.format('<a href="javascript: deleteItem(deleteCallback, {0});"><img src="../../images/icons/delete.png" title="Supprimer"/></a>', record.id);
            }
			
			var deleteCallback = function(btn){
                if (btn == 'yes') {
                    Ext.Ajax.request({
                        url: '../../servlet/ProductAccessoryHangServlet?action=2&id=' + deleteId,
                        success: function(o){
                            if (o.responseText == 'success') {
                                piHangStore.reload();
                                messageTip.msg(message.get('message.tip'), message.get('message.delete.successful'));
                            }
                            else {
                                messageTip.msg(message.get('message.tip'), message.get('message.delete.unsuccessful'));
                            }
                        },
                        failure: function(o){
                            messageTip.msg(message.get('message.tip'), message.get('message.delete.failure'));
                        },
                        params: {
                            foo: 'bar'
                        }
                    });
                }
            }
			
			var editCallback = function(){
				piHangForm.getForm().load({
					url:'../../servlet/ProductAccessoryHangServlet?action=3&id=' + editId, 
					waitMsg:Ext.LoadMask.prototype.msg, 
					success: function(form, action){
						if(Ext.getCmp('aoId2').getValue != ''){
							Ext.getCmp('ahSet').expand();
						}else{
							Ext.getCmp('ahSet').collapse();
						}
					}
				});
			}
			
        </script>
    </head>
    <body style="margin: 0 0 0 0;">
        <div id="productIdentification">
        </div>
        <div id="piAccessoryOthersForm">
        </div>
		 <div id="piAccessoryOthersList" style="margin-top: 5px;">
        </div>
    </body>
</html>
